<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
	debugger;
	var productionDate = '${medicine.productionDate}';
	$('input[name=productionDate]').val(productionDate.substring(0,10));
	$(function() {
		
		$('#medicineEditForm').form({
			url : '${ctx}/medicine/edit',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				progressClose();
				result = $.parseJSON(result);
				if (result.status.errorCode == 0) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('错误', result.status.errorMsg, 'error');
				}
			}
		});
		
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="padding: 3px;">
		<form id="medicineEditForm" method="post">
			<table class="grid">
				<tr>
					<td>药品名称</td>
					<td><input name="id" type="hidden"  value="${medicine.id}">
						<input name="name" type="text" class="easyui-validatebox" data-options="required:true,validType:'length[1,32]'" value="${medicine.name}">
					</td>
					<td>价格</td>
					<td>
						<input name="price" type="number" step="0.01" class="easyui-validatebox span2" data-options="required:true" value="${medicine.price}">
					</td>
				</tr>
				<tr>
					<td>保质期（天）</td>
					<td><input name="guranteePeriod" type="number" step="1" class="easyui-validatebox span2" data-options="required:true,validType:'checkNum'" value="${medicine.guranteePeriod}"></td>			
					<td>生产日期</td>
					<td><input name="productionDate" type="date" class="easyui-validatebox span2" data-options="required:true" value="${medicine.productionDate}"></td>		
				</tr>
				<tr>
					<td>功能主治(不超过512字)</td>
					<td colspan="3"><textarea name="effect" rows="5" cols="120" maxlength="512">${medicine.effect}</textarea></td></tr>
				<tr>
					<td>成分(不超过256字)</td>
					<td colspan="3"><textarea name="component" rows="6" cols="120" maxlength="256">${medicine.component}</textarea></td>
				</tr>
				<tr>
					<td>描述(不超过512字)</td>
					<td colspan="3"><textarea name="description" rows="5" cols="120" maxlength="512">${medicine.description}</textarea></td>
				</tr>
			</table>
		</form>
	</div>
</div>